using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.Globalization;

namespace Yorrick.Common
{
   /// <summary>
   /// Negates boolean values, i.e., <c>true</c> -> <c>false</c> and <c>false</c> -> <c>true</c>.
   /// </summary>
   [ValueConversion(typeof(bool), typeof(bool))]
   public class BooleanNegator : IValueConverter
   {
      /// <summary>
      /// Returns the negated boolean value.
      /// </summary>
      /// <param name="value">The value to negate.</param>
      /// <param name="targetType">Not used.</param>
      /// <param name="parameter">Not used.</param>
      /// <param name="culture">Not used.</param>
      /// <returns>The negated value.</returns>
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
         return !((bool)value);
      }

      /// <summary>
      /// Returns the negated boolean value.
      /// </summary>
      /// <param name="value">The value to negate.</param>
      /// <param name="targetType">Not used.</param>
      /// <param name="parameter">Not used.</param>
      /// <param name="culture">Not used.</param>
      /// <returns>The negated value.</returns>
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
         return !((bool)value);
      }
   }
}
